const { randomCenter } = require("../../../../common/compute")
const { debuger } = require("../../../../common/debuger")
const Processor = function() {
    this.process = function(type, object, runtime) {
        let current = runtime.current <= 0 ? 0 : runtime.current
        let width = (Math.max(device.width, device.height) - object.x * 2) / 5
        let position = {
            x: current * width + object.x,
            y: object.y + 10,
            w: width,
            h: 300,
            label: "角色" + (current + 1)
        }
        debuger.refresh()
        debuger.add(position)
        let target = randomCenter(position, 10)
        console.log("获取到点击坐标:" + JSON.stringify(target))
        click(target.x, target.y)
        toast("即将切换角色【" + (current + 1) + "】")
        sleep(1000)
        runtime.current = runtime.current <= 0 ? 1 : runtime.current + 1
        return true
    }
}

exports.switchCharacterProcessor = new Processor() 